package com.radiant.data.entity;

import java.util.Date;

import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.ConvertUtilsBean;

import com.radiant.data.entity.converter.DateConverter;
import com.radiant.data.entity.converter.EnumAwareConvertUtilsBean;

public abstract class SimpleDBCompoundType {

	private BeanUtilsBean beanUtilsBean;

	public SimpleDBCompoundType() {
		super();
	}

	protected final BeanUtilsBean getBeanUtilsBean() {
		if (beanUtilsBean == null) {
			beanUtilsBean = new BeanUtilsBean(new EnumAwareConvertUtilsBean());
			ConvertUtilsBean convertUtils = beanUtilsBean.getConvertUtils();
			convertUtils.register(new DateConverter(), Date.class);
			registerConverters(convertUtils);
		}
		return beanUtilsBean;
	}

	protected abstract void registerConverters(ConvertUtilsBean convertUtilsBean);

}